<?php
    require('./inc/common.php');
	
	$param = getParam($_GET);
	
	$data = false;
	
	if ($param['zoom'] > 13) {
		$sql = "SELECT t.type_id, t.type_name, t.type_area_lat, t.type_area_lng, t.zoom
		FROM zj_jigou j
		LEFT JOIN zj_type t ON j.jigou_street = t.type_id";
	}else{
    	$sql = "SELECT t.type_id, t.type_name, t.type_area_lat, t.type_area_lng, t.zoom
		FROM zj_jigou j 
		LEFT JOIN zj_type t ON j.jigou_area = t.type_id";
	}

    $result = mysql_query($sql);

    while ($row = mysql_fetch_assoc($result)) {
        if(isset($area[$row['type_name']])){
            $area[$row['type_name']]['num'] ++;
        }else{
            $area[$row['type_name']]['num'] = 1;
        }

        $area[$row['type_name']]['id'] = $row['type_id'];
        $area[$row['type_name']]['zoom'] = $row['zoom'];
        $area[$row['type_name']]['lat'] = $row['type_area_lat'];
        $area[$row['type_name']]['lng'] = $row['type_area_lng'];
    }
    mysql_free_result($result);

    foreach($area as $name => $detail){
        $data[$detail['id']] = array(
            'id' => $detail['id'],
            'cityid' => 11,
            'parent_id' => 7,
            'point_name' => $name,
            'lat' => $detail['lat'],
            'lng' => $detail['lng'],
            'zoom' => (int)$detail['zoom'],
            'type' => 2,
            'marker_data' => "",
            'propNum' =>  $detail['num'] . '个',
        );
    }

    header('Content-type: application/json');
    echo json_encode($data);